<h1 id="多语言支持"><a href="#多语言支持" class="headerlink" title="多语言支持"></a>多语言支持</h1><h2 id="基本用法"><a href="#基本用法" class="headerlink" title="基本用法"></a>基本用法</h2><p>现在，<code>Valine</code>开始支持多语言。默认内置：</p>
<ul>
<li><code>zh-cn</code></li>
<li><code>en</code></li>
</ul>
<pre><code class="js"><span class="keyword">var</span> valine = <span class="keyword">new</span> Valine();
valine.init({
    el:<span class="string">'.comment'</span>,
    appId:<span class="string">'your leancloud appid'</span>,
    appKey:<span class="string">'your leancloud appkey'</span>,
    lang:<span class="string">'en'</span> <span class="comment">// 设置这里就ok</span>
})
</code></pre>
<h2 id="自定义语言"><a href="#自定义语言" class="headerlink" title="自定义语言"></a>自定义语言</h2><p>!&gt; 如果有需要支持<code>其他语言</code>，请严格按照下面的<code>localeMode</code>格式书写内容:</p>
<pre><code class="js"><span class="keyword">var</span> localeName = <span class="string">'en'</span>,
    localeMode = {
        head:{
            nick:<span class="string">'NickName'</span>,
            mail:<span class="string">'E-Mail'</span>,
            link:<span class="string">'Website(http://)'</span>,
        },
        tips:{
            comments:<span class="string">'Comments'</span>,
            sofa:<span class="string">'No comments yet.'</span>,
            busy:<span class="string">'Submit is busy, please wait...'</span>,
            again:<span class="string">'Sorry, this is a wrong calculation.'</span>,
            limit:<span class="string">'The largest number of words %d'</span>
        },
        ctrl:{
            reply:<span class="string">'Reply'</span>,
            ok:<span class="string">'Ok'</span>,
            sure:<span class="string">'Sure'</span>,
            cancel:<span class="string">'Cancel'</span>,
            confirm:<span class="string">'Confirm'</span>,
            <span class="keyword">continue</span>:<span class="string">'Continue'</span>,
            more:<span class="string">'Load More...'</span>,
            <span class="keyword">try</span>:<span class="string">'Once More?'</span>,
        },
        error:{
            <span class="number">99</span>:<span class="string">'Initialization failed, Please check the `el` element in the init method.'</span>,
            <span class="number">100</span>:<span class="string">'Initialization failed, Please check your appId and appKey.'</span>,
            <span class="number">401</span>:<span class="string">'Unauthorized operation, Please check your appId and appKey.'</span>,
            <span class="number">403</span>:<span class="string">'Access denied by api domain white list, Please check your security domain.'</span>,
        },
        timeago:{
            seconds:<span class="string">'seconds ago'</span>,
            minutes:<span class="string">'minutes ago'</span>,
            hours:<span class="string">'hours ago'</span>,
            days:<span class="string">'days ago'</span>,
            now:<span class="string">'just now'</span>
        }
    };

<span class="keyword">var</span> valine = <span class="keyword">new</span> Valine();
<span class="comment">// 1.安装语言</span>
valine.installLocale(localeName,localeMode)
<span class="comment">// 2.初始化Valine</span>
valine.init({
    el:<span class="string">'.comment'</span>,
    appId:<span class="string">'your leancloud appid'</span>,
    appKey:<span class="string">'your leancloud appkey'</span>,
    lang:localeName
})
</code></pre>
<p>!&gt; <code>v1.1.8-beta9</code>开始支持。</p>
